<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>粉丝注册 - {:config('web.WEB_TIT')}</title>
	{include file="member/public"}
</head>
<body>
	<div class="logo"><img src="__MOBILE__/member_style/images/logo.png"/></div>
	<form>
		<input type="text" name="mobile" id="mobile" placeholder="请输入手机号" class="login-name">
		<input type="text" name="mobile_code" id="mobile_code" placeholder="请输入验证码" class="mobile_code"><span class="get_code" id="get_code">获取验证码</span>
		<input type="password" name="password" id="password" placeholder="请输入8-16位密码！" class="login-password">
		<input type="password" name="password_confirm" id="password_confirm" placeholder="再次输入密码" class="login-password">
		<input type="text" name="invitation_code" id="invitation_code" value="{$invitation_code}" placeholder="请输入邀请码" disabled="true" class="login-name">
		<div class="agree"><input type="checkbox" id="checkbox" name="checkbox" value="true" checked="">&nbsp;同意
			<a href="" class="reg1">《用户协议》</a></div>
		<input type="hidden" name="__token__" id="token" value="{$Request.token}" />
		<input type="submit" value="注册" id="register" class="money-btn">
	</form>
	<p class="login-text">已有账号,点此<a href="{:url('login/member_login')}" class="reg">登录</a></p>
	<script type="text/javascript">
        //点击提交按钮注册
        $('#register').click(function () {
            //检测
			var mobile = $('#mobile').val();
			var mobile_code = $('#mobile_code').val();
			var invitation_code = $('#invitation_code').val();
            var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;
            if(mobile == ''){
                alert('手机号码不能为空');
                return false;
            }else if(mobile_code == ''){
				alert('请输入验证码');
				return false;
			}else if(mobile.length !=11){
                alert('请输入长度11位的手机号码');
                return false;
            }else if(!myreg.test(mobile)){
                alert('请输入有效的手机号码');
                return false;
            }else if(invitation_code == ''){
                alert('请输入邀请码');
                return false;
			}

			var password = $('#password').val();
			var password_confirm = $('#password_confirm').val();
			if(password == ''){
                alert('密码不能为空');
                return false;
			}
            if(password.length < 8){
                alert('请输入8-16位密码');
                return false;
            }
            if(password.length > 16){
                alert('请输入8-16位密码');
                return false;
            }
			if(password != password_confirm){
                alert('两次密码输入不一致');
                return false;
			}

			var checkbox = $('#checkbox').val();
			if(!checkbox){
			    alert('请勾选用户协议');
                return false;
			}


            $.ajax({
                type: 'POST',
                url: '{:url("login/member_register")}',
                data: {
                    mobile:mobile,
                    password:password,
                    password_confirm:password_confirm,
                    checkbox:checkbox,
                    invitation_code:invitation_code,
                    token:$('#token').val(),
				},
                dataType:'json',
                success: function(data){
                    if(data.code == 200){
                        alert(data.msg)
                        window.location.href = "{:url('login/member_login')}";
                        // setTimeout(function(){
                        //     window.location.href = "{:url('member/login')}";
                        // },1000);
                    }else{
                        alert(data.msg)
                    }
                },
            });
        });

	</script>
</body>
</html>
